var ACTION = require("../../base/action");
var utils = require("../../utils/utils");
var actionGetAward = new ACTION("立即领取", {});
var ad = require("../appCommon/fanQieAd");
actionGetAward.start = function () {
  var content = "立即领取";
  var UIText = utils.clickTextStartsWith(content);
  if (UIText) {
    sleep(utils.getRandom(2.5, 3, 1000));
    return true;
  }
  return false;
};
actionGetAward.exec = function () {
  console.show(true);
  while (this.start()) {
    var contentRegExp = /看视频再领\d*金币/;
    if (utils.clickTextMatches(contentRegExp)) {
      ad.watchAd();
      sleep(2 * 1000);
      continue;
    }
    var contentRegExp = /看视频领最多\d*金币/;
    if (utils.clickTextMatches(contentRegExp)) {
      ad.watchAd();
      sleep(2 * 1000);
      continue;
    }
    var contentRegExp = /看视频最高再领\d*金币/;
    if (utils.clickTextMatches(contentRegExp)) {
      ad.watchAd();
      sleep(2 * 1000);
      continue;
    }
    sleep(2 * 1000);
  }
  console.hide();
};

module.exports = actionGetAward;
